<template>
  <div class="card">
<!--    <div style="margin-bottom: 10px;margin-left: 10px">待办统计</div>-->
    <div class="card_top">
      <div class="card_top_title">业务单处理</div>
      <div class="card_top_content">
        <div class="grid-container">
          <div class="grid-item" v-for="(item, index) in wgdList" :key="index">
            <div v-for="(data, dataIndex) in item">
              <hr v-if="item.length-1 === dataIndex && item.length !== 1" style="width: 90%;border: 0.5px solid #C0C4CC;">
              <div class="grid-item-content">
                <span @click="handleClick(data)" style="color: #606266;font-size: 13px">{{data.title}}: <span style="color: #F56C6C;">{{data.number}}</span></span>
              </div>
              <hr v-if="item.length-1 === dataIndex && item.length === 1" style="width: 90%;border: 0.5px solid #C0C4CC;">
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="card_bottom">
      <div class="card_top_title">其他业务</div>
      <div class="card_top_content">
        <div class="grid-container">
          <div class="grid-item" v-for="(item, index) in qtList" :key="index">
            <div v-for="(data, dataIndex) in item">
              <hr v-if="item.length-1 === dataIndex && item.length !== 1" style="width: 90%;border: 0.5px solid #C0C4CC;">
              <div class="grid-item-content">
                <span @click="handleClick(data)" style="color: #606266;font-size: 13px">{{data.title}}: <span style="color: #F56C6C;">{{data.number}}</span></span>
              </div>
              <hr v-if="item.length-1 === dataIndex && item.length === 1" style="width: 90%;border: 0.5px solid #C0C4CC;">
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { getDbNum } from '@/api/home'
export default {
  name: 'Statistics',
  data() {
    return {
      wgdList: [],
      qtList: []
    }
  },
  created() {
    this.getList()
  },
  watch: {
    '$route': {
      immediate: true,
      async handler(route) {
        this.getList()
      },
      deep: true
    },
  },
  methods: {
    getList() {
      getDbNum().then(res => {
        this.wgdList = res.wgdList
        this.qtList = res.qtList
      })
    },
    handleClick(row) {
      this.$router.push({ path: row.path, query: { sy: "true", type: row.type} });
      // if (row.type === 1) {  // 通知用户下场
      //
      // }else if (row.type === 2) {  // 待做完工单
      //   this.$router.push("/gd/ywd")
      // }else if (row.type === 3) {  // 用户已确认完工单
      //
      // }else if (row.type === 4) {  // 待申请电子证书
      //
      // }else if (row.type === 5) {  // 电子档未发客户
      //
      // }else if (row.type === 6) {  // 待打印纸质证书
      //
      // }else if (row.type === 7) {  // 纸质未邮寄给客户
      //
      // }else if (row.type === 8) {  // 未开发票
      //
      // }else if (row.type === 9) {  // 未回款
      //
      // }
    }
  }
}
</script>

<style scoped>
.card {
  width: 100%;
  height: 370px;
  /*padding-left: 10px;*/
  /*padding-right: 10px;*/
  /*background-color: white;*/
  /*border: 1px solid #DCDFE6;*/
  /*border-radius: 10px*/
}

.card_top {
  width: 100%;
  height: 180px;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 5px;
  background-color: white;
  border: 1px solid #DCDFE6;
  display: flex;
  flex-direction: column;
}

.card_top_title {
  width: 100%;
  height: 30px;
}

.card_top_content {
  width: 100%;
  height: 150px;
}

.card_bottom {
  width: 100%;
  height: 180px;
  border-radius: 10px;
  padding: 10px;
  background-color: white;
  border: 1px solid #DCDFE6;
}


.grid-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: minmax(100px, auto);
  gap: 10px;
}

.grid-item {
  background-color: #EEEEEE;
  width: 100%;
  height: 100%;
  border-radius: 10px
}

/* 隐藏多余的格子 */
.grid-item:nth-child(n+8) {
  display: none;
}

.grid-item-content {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

</style>
